/* 移动端适配优化 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

html {
    font-size: 16px;
}

body {
    font-family: 'Microsoft YaHei', 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
    line-height: 1.5;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    text-align: center;
    padding: 20px 15px;
}

header h1 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    word-wrap: break-word;
}

header p {
    font-size: 0.95rem;
    opacity: 0.9;
    line-height: 1.4;
}

.input-section {
    padding: 20px 15px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
    color: #333;
    font-size: 1rem;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 14px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    -webkit-appearance: none; /* 移除iOS默认样式 */
    appearance: none;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

.form-group input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 2px dashed #ccc;
    border-radius: 8px;
    background: #f8f9fa;
    cursor: pointer;
    transition: border-color 0.3s ease;
    font-size: 1rem;
}

.form-group input[type="file"]:active {
    border-color: #4facfe;
    background: #f0f8ff;
}

.preview-container {
    margin-top: 8px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    background: #f8f9fa;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.9rem;
}

.preview-container img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.generate-btn, .download-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
    min-height: 50px; /* 触摸友好的按钮高度 */
    display: flex;
    align-items: center;
    justify-content: center;
}

.generate-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.generate-btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.4);
}

.generate-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.download-btn {
    background: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
    color: white;
}

.download-btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(48, 207, 208, 0.4);
}

.card-section {
    padding: 20px 15px;
    border-top: 2px solid #f0f0f0;
}

.card-section h2 {
    text-align: center;
    margin-bottom: 15px;
    color: #333;
    font-size: 1.3rem;
}

.card-preview {
    text-align: center;
    margin-bottom: 15px;
    overflow-x: auto; /* 防止Canvas溢出 */
}

#cardCanvas {
    max-width: 100%;
    height: auto;
    border: 3px solid #f0f0f0;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    display: block;
}

/* 移动端优化 */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    body {
        padding: 5px;
    }
    
    .container {
        border-radius: 12px;
    }
    
    header {
        padding: 15px 10px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .input-section, .card-section {
        padding: 15px 10px;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-group input[type="text"],
    .form-group input[type="file"] {
        padding: 12px 10px;
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    .generate-btn, .download-btn {
        padding: 14px;
        font-size: 1rem;
        min-height: 48px;
    }
    
    #cardCanvas {
        width: 100%;
        max-width: 100vw;
        height: auto;
    }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    html {
        font-size: 13px;
    }
    
    header h1 {
        font-size: 1.3rem;
    }
    
    .preview-container {
        min-height: 60px;
        padding: 10px;
    }
    
    .preview-container img {
        max-height: 120px;
    }
}

/* 横屏优化 */
@media (max-width: 768px) and (orientation: landscape) {
    body {
        padding: 8px;
    }
    
    .container {
        max-height: 95vh;
        overflow-y: auto;
    }
    
    #cardCanvas {
        max-height: 60vh;
    }
}

/* 防止输入框在iOS上缩放 */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="file"] {
        font-size: 16px !important;
    }
}